package com.example.controller;

import com.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/users")
public class UsersController {

    @Autowired
    private UserService userService;

    /* /ssm_project/users/getById?id=1 */
    @RequestMapping("/getById")
    @ResponseBody
    public Object getUserById(int id) {
        System.out.println("通过id查询单个");
        // JSON springmvc
        System.out.println(userService.getUsersById(id));
        // 超文本能传输对象吗？
        return userService.getUsersById(id);
    }
}
